package com.candy.testOfIO;

import java.io.Serializable;

/**
 * @author donglin
 * @Title:
 * @类名: Student 可序列化
 * @date 2020/5/28
 */
//实现Serializable接口，表示该类可被序列化
    //序列化准备工作：1、需要有setter、getter方法；2、需要有无参构造（建议显示声明）3、实现Serializable接口
public class Student implements Serializable {
    //序列化版本号，显示声明，不声明可能会导致反序列化的时候发生异常
    static final long serialVersionUID = 1L;
    private String stuName;
    //加上transient关键字，则该属性不会序列化
    private transient int stuNo;
    private  boolean stuSex;

    public Student() {
    }

    public Student(String stuName, int stuNo, boolean stuSex) {
        this.stuName = stuName;
        this.stuNo = stuNo;
        this.stuSex = stuSex;
    }

    public String getStuName() {
        return stuName;
    }

    public void setStuName(String stuName) {
        this.stuName = stuName;
    }

    public int getStuNo() {
        return stuNo;
    }

    public void setStuNo(int stuNo) {
        this.stuNo = stuNo;
    }

    public boolean isStuSex() {
        return stuSex;
    }

    public void setStuSex(boolean stuSex) {
        this.stuSex = stuSex;
    }

    @Override
    public String toString() {
        return "Student{" +
                "stuName='" + stuName + '\'' +
                ", stuNo=" + stuNo +
                ", stuSex=" + stuSex +
                '}';
    }
}
